package hr.ctg.domain.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "cijena")
@NamedQueries( { @NamedQuery(name = "Cijena.findByIdObjekta", query = "select c from Cijena c where c.objekt.idObjekta = ?") })
public class Cijena implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id_cijene")
	private Integer idCijene;
	@Temporal(TemporalType.DATE)
	@Column(name = "datum_od")
	private Date datumOd;
	@Temporal(TemporalType.DATE)
	@Column(name = "datum_do")
	private Date datumDo;

	private Float dan;

	private Float jednokrevetna;

	private Float dvokrevetna;

	private Float trokrevetna;

	private Float apartman;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_objekta", nullable = true)
	private Objekt objekt;

	private static final long serialVersionUID = 1L;

	public Cijena() {
		super();
	}

	public Integer getIdCijene() {
		return idCijene;
	}

	public void setIdCijene(final Integer idCijene) {
		this.idCijene = idCijene;
	}

	public Date getDatumOd() {
		return datumOd;
	}

	public void setDatumOd(final Date datumOd) {
		this.datumOd = datumOd;
	}

	public Date getDatumDo() {
		return datumDo;
	}

	public void setDatumDo(final Date datumDo) {
		this.datumDo = datumDo;
	}

	public Float getDan() {
		return dan;
	}

	public void setDan(final Float dan) {
		this.dan = dan;
	}

	public Float getJednokrevetna() {
		return jednokrevetna;
	}

	public void setJednokrevetna(final Float jednokrevetna) {
		this.jednokrevetna = jednokrevetna;
	}

	public Float getDvokrevetna() {
		return dvokrevetna;
	}

	public void setDvokrevetna(final Float dvokrevetna) {
		this.dvokrevetna = dvokrevetna;
	}

	public Float getTrokrevetna() {
		return trokrevetna;
	}

	public void setTrokrevetna(final Float trokrevetna) {
		this.trokrevetna = trokrevetna;
	}

	public Float getApartman() {
		return apartman;
	}

	public void setApartman(final Float apartman) {
		this.apartman = apartman;
	}

	// @Override
	// public int hashCode() {
	// final int prime = 31;
	// int result = 1;
	// result = prime * result + idCijene;
	// return result;
	// }

	@Override
	public boolean equals(final Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}

		final Cijena other = (Cijena) obj;
		if (getIdCijene() != other.getIdCijene()) {
			return false;
		}
		return true;
	}

	public Objekt getObjekt() {
		return objekt;
	}

	public void setObjekt(final Objekt objekt) {
		this.objekt = objekt;
	}

	@Override
	public String toString() {
		return "" + idCijene;
	}

}
